package org.hackystat.timeline.service;

import static org.junit.Assert.assertNotNull;

import java.io.File;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.datatype.DatatypeConfigurationException;


import org.hackystat.sensorbase.resource.sensordata.jaxb.SensorData;
import org.junit.Test;


/**
 * Tests for file dispatchinig.
 * @author Alexey R. Olkov
 *
 */
public class TestFileDispatcher {

  /**
   * Checks the data retrieved from the JAXB unmarshaller.
   * @throws JAXBException if a problem occurs.
   * @throws DatatypeConfigurationException if a problem occurs.
   */
  @Test public void testUnmarshller() throws JAXBException, DatatypeConfigurationException {
    JAXBContext context = JAXBContext
        .newInstance("org.hackystat.sensorbase.resource.sensordata.jaxb");
    Unmarshaller unmarshaller = context.createUnmarshaller();
    SensorData sensorData = (SensorData) unmarshaller.unmarshal(new File(
        "xml\\project1\\user1\\sensordatatype\\unittest\\1-2006-10-23.xml"));
    assertNotNull("Cheking the object", sensorData);
    assertNotNull("Cheking the runtime", sensorData.getRuntime());
    assertNotNull("Checking calendar", sensorData.getTimestamp());
  }
}
